package com.leadnews.wemedia.controller.v1;

import com.leadnews.model.common.dtos.ResponseResult;
import com.leadnews.model.wemedia.dtos.WmNewsDto;
import com.leadnews.model.wemedia.dtos.WmNewsPageReqDto;
import com.leadnews.model.wemedia.pojos.WmNews;
import com.leadnews.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto dto) {
        return wmNewsService.findList(dto);
    }

    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto) {
        return wmNewsService.submitNews(dto);
    }


    /**
     * 上架、下架文章
     * @param dto
     * @return
     */
    @PostMapping("/down_or_up")
    public ResponseResult downOrUpNews(@RequestBody WmNews dto){
        return wmNewsService.downOrUpNews(dto);
    }

}
